﻿import { Injectable } from '@angular/core';
import { AppLocalizationService } from '@app/shared/common/localization/app-localization.service';
import * as moment from 'moment';
import { monitorEventLoopDelay } from 'perf_hooks';
// import { CostZT_ContractServiceProxy } from '@shared/service-proxies/cost-service-proxies';
// import { Base_ErpDateServiceProxy } from '@shared/service-proxies/stock-service-proxies';

@Injectable()
export class DateTimeService {
    constructor(
        private _appLocalizationService: AppLocalizationService,
        // private _dateservice: Base_ErpDateServiceProxy
    ) {}

    date = new Date();

    createDateRangePickerOptions(): any {
        let options = {
            locale: {
                format: 'L',
                applyLabel: this._appLocalizationService.l('Apply'),
                cancelLabel: this._appLocalizationService.l('Cancel'),
                customRangeLabel: this._appLocalizationService.l('CustomRange')
            },
            min: moment('2015-05-01'),
            minDate: moment('2015-05-01'),
            max: moment(),
            maxDate: moment(),
            opens: 'left',
            ranges: {}
        };

        options.ranges[this._appLocalizationService.l('Today')] = [moment().startOf('day'), moment().endOf('day')];
        options.ranges[this._appLocalizationService.l('Yesterday')] = [
            moment()
                .subtract(1, 'days')
                .startOf('day'),
            moment()
                .subtract(1, 'days')
                .endOf('day')
        ];
        options.ranges[this._appLocalizationService.l('Last7Days')] = [
            moment()
                .subtract(6, 'days')
                .startOf('day'),
            moment().endOf('day')
        ];
        options.ranges[this._appLocalizationService.l('Last30Days')] = [
            moment()
                .subtract(29, 'days')
                .startOf('day'),
            moment().endOf('day')
        ];
        options.ranges[this._appLocalizationService.l('ThisMonth')] = [
            moment().startOf('month'),
            moment().endOf('month')
        ];
        options.ranges[this._appLocalizationService.l('LastMonth')] = [
            moment()
                .subtract(1, 'month')
                .startOf('month'),
            moment()
                .subtract(1, 'month')
                .endOf('month')
        ];

        return options;
    }

    public changeinitdate(): Date {
  
        // this._dateservice.changeDate(moment()).subscribe(result => {
        //     this.date = result.toDate();
        //     return   this.date;
        // });
       return this.date;
        
      
    }
}
